
/**
 * Utilty class to perform DNS lookups for XMPP services.
 *
 * @author Matt Tucker
 */
class DNSUtil {
public:
	
    /**
     * Encapsulates a hostname and port.
     */
    class HostAddress {
	public:
        /**
         * Returns the hostname.
         *
         * @return the hostname.
         */
		std::string getHost() {
            return host;
        }

        /**
         * Returns the port.
         *
         * @return the port.
         */
        int getPort() {
            return port;
        }

		std::string toString() {
            return host + ":" + port;
        }

		bool operator==(const HostAddress * const hostAddress) const {
			return host == hostAddress->host && port == hostAddress->port;
        }
	private:
        std::string host;
        int port;

        HostAddress(std::string & host, int port) {
            this->host = host;
            this->port = port;
        }
    };

	/**
     * Returns the host name and port that the specified XMPP server can be
     * reached at for client-to-server communication. A DNS lookup for a SRV
     * record in the form "_xmpp-client._tcp.example.com" is attempted, according
     * to section 14.4 of RFC 3920. If that lookup fails, a lookup in the older form
     * of "_jabber._tcp.example.com" is attempted since servers that implement an
     * older version of the protocol may be listed using that notation. If that
     * lookup fails as well, it's assumed that the XMPP server lives at the
     * host resolved by a DNS lookup at the specified domain on the default port
     * of 5222.<p>
     *
     * As an example, a lookup for "example.com" may return "im.example.com:5269".
     *
     * @param domain the domain.
     * @return a HostAddress, which encompasses the hostname and port that the XMPP
     *      server can be reached at for the specified domain.
     */
    static HostAddress * resolveXMPPDomain(std::string & domain) ;

    /**
     * Returns the host name and port that the specified XMPP server can be
     * reached at for server-to-server communication. A DNS lookup for a SRV
     * record in the form "_xmpp-server._tcp.example.com" is attempted, according
     * to section 14.4 of RFC 3920. If that lookup fails, a lookup in the older form
     * of "_jabber._tcp.example.com" is attempted since servers that implement an
     * older version of the protocol may be listed using that notation. If that
     * lookup fails as well, it's assumed that the XMPP server lives at the
     * host resolved by a DNS lookup at the specified domain on the default port
     * of 5269.<p>
     *
     * As an example, a lookup for "example.com" may return "im.example.com:5269".
     *
     * @param domain the domain.
     * @return a HostAddress, which encompasses the hostname and port that the XMPP
     *      server can be reached at for the specified domain.
     */
    static HostAddress * resolveXMPPServerDomain(std::string & domain) ;

private:



}
